package cn.ffcs.unm.assess.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.StringEscapeUtils;
import org.springframework.stereotype.Repository;

import cn.ffcs.unm.assess.dao.AssessDao;
import cn.ffcs.unm.assess.model.Assess;
import cn.ffcs.uom.common.dao.BaseDaoImpl;
import cn.ffcs.uom.common.util.StrUtil;
import cn.ffcs.uom.common.vo.PageInfo;

@Repository("assessDao")
public class AssessDaoImpl extends BaseDaoImpl implements AssessDao {
	@Override
	public PageInfo queryAssessPage(Assess assess, int currentPage,int pageSize) {
		StringBuilder sql = new StringBuilder();
		sql.append(" select * from  VIEW_HI_PSNDOC_ASS  V where 1 = 1 ");
		List<Object> params = new ArrayList<Object>();
			if (assess != null) {
				if (!StrUtil.isEmpty(assess.getMonthId())) {
					sql.append(" AND V.monthId = ? ");
					params.add(assess.getMonthId());
				}
				if (!StrUtil.isNullOrEmpty(assess.getOrgName())) {
					sql.append(" AND V.orgname like ?");
					params.add("%" + StringEscapeUtils.escapeSql(assess.getOrgName()) + "%");
				}
				if (!StrUtil.isNullOrEmpty(assess.getStaffName())) {
					sql.append(" and V.staffName like ?");
					params.add("%" + StringEscapeUtils.escapeSql(assess.getStaffName()) + "%");
				}
			return super.jdbcFindPageInfo(sql.toString(), params, currentPage,
					pageSize, Assess.class);
		}

		return null;
	}
	
}
